using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace Millis.Controls
{
    internal class FileData
    {
        private string _filePath;
        private long _legnth;
        private string _legnthStr;

        /// <summary>
        /// Gets the file path.
        /// </summary>
        /// <value>The file path.</value>
        public string FilePath
        {
            get { return _filePath; }
        }

        /// <summary>
        /// Gets the legnth.
        /// </summary>
        /// <value>The legnth.</value>
        public long Legnth
        {
            get { return _legnth; }
        }

        /// <summary>
        /// Gets the legnth string.
        /// </summary>
        /// <value>The legnth string.</value>
        public string LegnthString
        {
            get
            {
                return _legnthStr;
            }

        }

        /// <summary>
        /// Initializes a new instance of the <see cref="FileData"/> class.
        /// </summary>
        /// <param name="filePath">The file path.</param>
        /// <param name="length">The length.</param>
        public FileData(string filePath, long length)
        {
            _filePath = filePath;
            _legnth = length;

            double size = (double)_legnth;
            if (size < 1024)
                _legnthStr = string.Format("{0:N} B", size);
            else if (size < Math.Pow(1024, 2))
                _legnthStr = string.Format("{0:N1} KB", size / 1024);
            else if (size < Math.Pow(1024, 3))
                _legnthStr = string.Format("{0:N1} MB", size / Math.Pow(1024, 2));
            else
                _legnthStr = string.Format("{0:N1} GB", size / Math.Pow(1024, 3));
        }

    }
}
